// components/toTop/toTop.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {},
  /**
   * 组件的初始数据
   */
  data: {
    isShow: false,
  },
  attached() {
    let { windowHeight } = wx.getSystemInfoSync();
    this.createIntersectionObserver({})
      .relativeToViewport({})
      .observe(".anchor", (e) => {
        this.setData({
          isShow: e.intersectionRatio !== 1,
        });
      });
  },
  /**
   * 组件的方法列表
   */
  methods: {
    toTop() {
      wx.pageScrollTo({
        scrollTop: 0,
      });
    },
  },
});
